﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Satates.CMStates;

namespace Operators.CMOperators
{
    public class Move2MissionaryRight:iOperator
    {
        public override string ToString()
        {

            return "Move 2 Missionary Right";
        }

        public int getOperatorNumber()
        {
            return 8;
        }

        public Common.Template execute(Common.Template t)
        {
            CMState s2 = (CMState)t;
            s2.setLeftMissionaries(s2.getLeftMissionaries() - 2);
            s2.setRightMissionaries(s2.getRightMissionaries() + 2);
            s2.setBoat("right");
            return s2;
        }

        public bool available(Common.Template t)
        {
            CMState s = (CMState)t;
            if (s.getBoat().Equals("left"))
                if (s.getLeftMissionaries() >= 2)
                    if ((s.getLeftMissionaries() - 2 >= s.getLeftCanibals()) || (s.getLeftMissionaries() - 2 == 0))
                        if (s.getRightMissionaries() + 2 >= s.getRightCanibals())
                            return true;
            return false;
        }
        public object Clone()
        {
            return this.MemberwiseClone();
        }
    }
}
